package nullby.yoga.bo;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Programm {
	private final String ICON = "icon";
	private final String ID = "id";
	private final String NAME = "name";
	private final String DESCRIPTION = "description";
	private final String POSITIONS = "positions";

	private String icon;
	private String id;
	private String name;
	private String description;
	private ArrayList<Content> positions;

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public ArrayList<Content> getPositions() {
		return positions;
	}

	public void setPositions(ArrayList<Content> positions) {
		this.positions = positions;
	}

	public ArrayList<CharSequence> getPositionsIcons() {
		ArrayList<CharSequence> result = new ArrayList<CharSequence>();
		for (Content position : positions) {
			result.add((CharSequence) position.getIcon());
		}
		return result;
	}

	public ArrayList<CharSequence> getPositionsNames() {
		ArrayList<CharSequence> result = new ArrayList<CharSequence>();
		for (Content position : positions) {
			result.add((CharSequence) position.getName());
		}
		return result;
	}

	public ArrayList<CharSequence> getPositionsDescriptions() {
		ArrayList<CharSequence> result = new ArrayList<CharSequence>();
		for (Content position : positions) {
			result.add((CharSequence) position.getDescription());
		}
		return result;
	}

	public Programm(String icon, String id, String name, String description,
			ArrayList<Content> positions) {
		super();
		this.icon = icon;
		this.id = id;
		this.name = name;
		this.description = description;
		this.positions = positions;
	}

	public Programm(JSONObject jo) throws JSONException {
		this.icon = jo.getString(ICON);
		this.id = jo.getString(ID);
		this.name = jo.getString(NAME);
		this.description = jo.getString(DESCRIPTION);
		this.positions = new ArrayList<Content>();
		JSONArray ja = jo.getJSONArray(POSITIONS);
		for (int i = 0; i < ja.length(); i++) {
			this.positions.add(new Content(ja.getJSONObject(i)));
		}
	}

	public Programm(String string) {

	}

}